import React, { useImperativeHandle, useState } from 'react';
import {
  List,
  InputItem,
  DatePicker,
  TextareaItem,
  Checkbox,
  Button,
} from 'antd-mobile';
import SelfInput from 'components/common/selfInput';
import Cascade from 'components/common/cascade';
import Star from 'components/common/star';
import getYears from 'utils/getYears';

import './index.less';

// 企业概况
function CompProfile({ item, cRef }) {
  const [companyName, setCompanyName] = useState('');
  const [establishmentTime, setEstablishmentTime] = useState('');
  const [registerMoney, setRegisterMoney] = useState('');
  const [turnover, setTurnover] = useState('');
  const [employeeQuantity, setEmployeeQuantity] = useState('');
  const [briefIntroduction, setBriefIntroduction] = useState('');
  useImperativeHandle(cRef, () => ({
    companyName,
    establishmentTime,
    registerMoney,
    turnover,
    employeeQuantity,
    briefIntroduction,
  }));
  return (
    <>
      <SelfInput
        label="公司名称"
        isRequired={true}
        rule={{
          len: 2,
          empty: '请输入公司名称',
          error: '请正确输入公司名称',
        }}
        handleInputChange={v => setCompanyName(v)}
      />
      <Cascade
        label="成立时间"
        data={getYears()}
        cols={1}
        handleOnChange={v => setEstablishmentTime(v + '')}
      />
      <SelfInput
        label="注册资金"
        isRequired={true}
        rule={{
          len: 1,
          empty: '请输入注册资金',
          error: '请正确输入注册资金',
        }}
        unit="万"
        type="digit"
        handleInputChange={v => setRegisterMoney(v)}
      />
      <SelfInput
        label="营业额"
        isRequired={true}
        rule={{
          len: 1,
          empty: '请输入营业额',
          error: '请正确输入营业额',
        }}
        unit="万"
        type="digit"
        handleInputChange={v => setTurnover(v)}
      />
      <SelfInput
        label="员工数量"
        isRequired={true}
        rule={{
          len: 1,
          empty: '请输入员工数量',
          error: '请正确输入员工数量',
        }}
        type="digit"
        unit="人"
        handleInputChange={v => setEmployeeQuantity(v)}
      />
      <div className="compIntr">
        <Star />
        公司简介
      </div>
      <TextareaItem onChange={v => setBriefIntroduction(v)} />
    </>
  );
}
export default CompProfile;
